package com.czh.controller;


import com.czh.domain.ResponseResult;
import com.czh.domain.vo.ArticlePageVo;
import com.czh.domain.vo.ArticleShowDetailVo;
import com.czh.domain.vo.ArticleShowVo;
import com.czh.domain.vo.HotArticleVo;
import com.czh.service.ArticleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文章表(Article)表控制层
 *
 * @author caozaihui
 * @since 2024-03-17 23:02:28
 */
@RestController
@RequestMapping("/article")
public class ArticleController  {
    /**
     * 服务对象
     */
    @Resource
    private ArticleService articleService;

    @GetMapping("/hotArticleList")
    public ResponseResult<List<HotArticleVo>> hotArticleList(){
        return articleService.hotArticleList();
    }
    @GetMapping("/articleList")
    public ResponseResult<ArticlePageVo<ArticleShowVo>> articleList(Integer pageNum, Integer pageSize, Long categoryId){
        return articleService.articleList(pageNum,pageSize,categoryId);
    }
    @GetMapping("/{id}")
    public ResponseResult<ArticleShowDetailVo> getArticleDetail(@PathVariable("id") Long id){
        return articleService.getArticleDetail(id);
    }
    @PutMapping("/updateViewCount/{id}")
    public ResponseResult<Object> updateViewCount(@PathVariable("id") Long id){
        return articleService.updateViewCount(id);
    }
}

